
********************************************************************************
* Replication do file for "How Urban Rios Influence Political Behaviour:       *
* Vote Choices after the 2011 London riots"                                    *
* Authors: Gabriel Leon-Ablan and Peter John                                   *
********************************************************************************


clear

* Set plotting scheme
set scheme plotplainblind

* Choose your working directory. This script and all four source datasets should be located in the same folder
* These datasets are: mayor_elections.dta, robustness_distance.dta, placebo1.dta, placebo2.dta




* The estimation requires the installation of the ols_spatial_HAC command. Please see the README.txt file for
* instructions on how to install this command.





				*********************
				***** MAIN TEXT *****
				*********************


clear
use mayor_elections.dta

gen yearD=1
gen boroughD=1
gen constant=1

label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"



************************************************
* Table 1: Turnout and Conservative vote share *
* 1) treatment = near the riots                *
* 2) treatment = near the rioters              *
************************************************

* Turnout *

xi: ols_spatial_HAC turnout_pc treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
estimates store tab1a
outreg2 using Table1, tex(frag) auto(2) asterisk(se) ctitle(turnout) replace sortvar(time treated did charged_d did_charged) label alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC turnout_pc charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
estimates store tab1b
outreg2 using Table1, tex(frag) auto(2) asterisk(se) ctitle(turnout) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Vote against the Tories *

xi: ols_spatial_HAC share_total_Con treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
estimates store tab1c
outreg2 using Table1, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


xi: ols_spatial_HAC share_total_Con charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
estimates store tab1d
outreg2 using Table1, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)



**************************************************************
* Table 2: Turnout and Conservative vote share, by ethnicity *
* 1) treatment = near the riots                              *
* 2) treatment = near the rioters                            *
**************************************************************

clear
use mayor_elections.dta

gen yearD=1
gen boroughD=1
gen constant=1

label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"


* Turnout (whites)
xi: ols_spatial_HAC beta_turn_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using Table2, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab replace alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_turn_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using Table2, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)



* Turnout (Blacks)
xi: ols_spatial_HAC beta_turn_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using Table2, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_turn_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using Table2, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Vote Conservative (whites)
xi: ols_spatial_HAC beta_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using Table2, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using Table2, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)



* Vote Conservative (Blacks)
xi: ols_spatial_HAC beta_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using Table2, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 			0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using Table2, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 			0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)






				***************************
				***** ONLINE APPENDIX *****
				***************************

				



******************************************
* Table A1 and A2: Balance checks tables *
******************************************

clear
use mayor_elections.dta
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

* Table A1:
iebaltab unemployment fraction_white fraction_black fraction_high_qual crime_rate10, grpvar(treated) vce(cluster ward_mayorN) ftest savetex(TableA1) replace


* Table A2:
iebaltab unemployment fraction_white fraction_black fraction_high_qual crime_rate10, grpvar(charged_d) vce(cluster ward_mayorN) ftest savetex(TableA2) replace




************************************
* Figures A1 and A2: Common trends *
************************************


* Figure A1
clear
use mayor_elections.dta
collapse (mean) share_total_Con, by (treated year)
reshape wide share_total_Con, i(year) j(treated)
graph twoway scatter share_total_Con0 share_total_Con1 year || line share_total_Con0 share_total_Con1 year, sort xline(2011) lwidth(1) lcolor(1)
graph export FigureA1.pdf, replace

* Figure A2
clear
use mayor_elections.dta
collapse (mean) share_total_Lab, by (treated year)
reshape wide share_total_Lab, i(year) j(treated)
graph twoway scatter share_total_Lab0 share_total_Lab1 year || line share_total_Lab0 share_total_Lab1 year , sort xline(2011) lwidth(1) lcolor(1)
graph export FigureA2.pdf, replace


**********************************
* Table A3: Shift towards Labour *
**********************************

clear
use mayor_elections.dta
keep if year==2004 | year==2008
sort borough ward_mayor

gen share_total_Lab04=0
replace share_total_Lab04=share_total_Lab if year==2004
gen share_total_Lab08=0
replace share_total_Lab08=share_total_Lab if year==2008

egen share_total_Lab_04=sum(share_total_Lab04), by(borough ward_mayorN)
egen share_total_Lab_08=sum(share_total_Lab08), by(borough ward_mayorN)

label var share_total_Lab_04 "share Labour vote (2004)"
label var share_total_Lab_08 "share Labour vote (2008)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

keep treated charged_d fraction_black fraction_white unemployment fraction_high_qual crime_rate10 borough ward_mayorN latitude longitude share_total_Lab_08 share_total_Lab_04 share_total_Lab_04 share_total_Lab_08

gen Lab_change_04_08= share_total_Lab_08 - share_total_Lab_04
duplicates drop

gen time=1
encode borough, gen(boroughN)


* Table A3
xi: ols_spatial_HAC share_total_Lab_08 share_total_Lab_04 treated fraction_black fraction_white i.borough, panelvar(ward_mayorN) timevar(time) lat(latitude) lon(longitude) disp
outreg2 using TableA3, tex(frag) auto(2) asterisk(se) ctitle(share Labour 2008) sortvar(time treated did charged_d did_charged) lab replace alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Lab_08 share_total_Lab_04 treated fraction_black fraction_white fraction_high_qual i.borough, panelvar(ward_mayorN) timevar(time) lat(latitude) lon(longitude) disp
outreg2 using TableA3, tex(frag) auto(2) asterisk(se) ctitle(share Labour 2008) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Lab_08 share_total_Lab_04 treated fraction_black fraction_white fraction_high_qual unemployment crime_rate10 i.borough, panelvar(ward_mayorN) timevar(time) lat(latitude) lon(longitude) disp
outreg2 using TableA3, tex(frag) auto(2) asterisk(se) ctitle(share Labour 2008) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Lab_08 share_total_Lab_04 charged_d fraction_black fraction_white i.borough, panelvar(ward_mayorN) timevar(time) lat(latitude) lon(longitude) disp
outreg2 using TableA3, tex(frag) auto(2) asterisk(se) ctitle(share Labour 2008) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Lab_08 share_total_Lab_04 charged_d fraction_black fraction_white fraction_high_qual i.borough, panelvar(ward_mayorN) timevar(time) lat(latitude) lon(longitude) disp
outreg2 using TableA3, tex(frag) auto(2) asterisk(se) ctitle(share Labour 2008) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Lab_08 share_total_Lab_04 charged_d fraction_black fraction_white fraction_high_qual unemployment crime_rate10 i.borough, panelvar(ward_mayorN) timevar(time) lat(latitude) lon(longitude) disp
outreg2 using TableA3, tex(frag) auto(2) asterisk(se) ctitle(share Labour 2008) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)



**************************************************************************************
* Table A4: Proportion of wards treated under 1, treated under 2, treated under both *
**************************************************************************************

clear
use mayor_elections.dta

keep if year==2012


gen treatment2 = treated
label var treatment2 "near riot"
gen treatment1 = charged_d
label var treatment1 "near rioter home"

tabulate treatment1 treatment2
tabout treatment1 treatment2 using TableA4.doc, replace 


*************************************************************************************************************
* Figures A3 and A4: Plot change in Conservative vote share and change in turnout versus distance from riot *
*************************************************************************************************************
clear
use mayor_elections.dta

gen yearD=1
gen boroughD=1
gen constant=1

keep if year==2008
gen Con_ch_08=share_total_Con
gen Lab_ch_08=share_total_Lab
gen turnout_ch_08=turnout_pc
keep borough ward_mayor Con_ch_08 Lab_ch_08 turnout_ch_08
save temp_08.dta, replace



clear
use mayor_elections.dta

gen yearD=1
gen boroughD=1
gen constant=1

keep if year==2012
gen Con_ch_12=share_total_Con
gen Lab_ch_12=share_total_Lab
gen turnout_ch_12=turnout_pc
keep borough ward_mayor Con_ch_12 Lab_ch_12 turnout_ch_12
save temp_12.dta, replace



clear
use mayor_elections.dta

gen yearD=1
gen boroughD=1
gen constant=1

merge m:1 borough ward_mayor using temp_08.dta
drop _merge
merge m:1 borough ward_mayor using temp_12.dta


gen Con_ch_08_12 = Con_ch_12 - Con_ch_08
gen Lab_ch_08_12 = Con_ch_12 - Lab_ch_08
gen turnout_ch_08_12 = turnout_ch_12 - turnout_ch_08

keep if year==2012

label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

gen distance2=distance*distance

* Figure A3
xi: ols_spatial_HAC turnout_ch_08_12 distance distance2 i.year i.borough, panelvar(boroughN) timevar(year) lat(latitude) lon(longitude) disp
twoway scatter turnout_ch_08_12 distance, mcolor(*.4) || lowess turnout_ch_08_12 distance, lwidth(1) lcolor(1)
graph export FigureA3.pdf, replace

* Figure A4
xi: ols_spatial_HAC Lab_ch_08_12 distance distance2 i.year i.borough, panelvar(boroughN) timevar(year) lat(latitude) lon(longitude) disp
twoway scatter Lab_ch_08_12 distance, mcolor(*.4) || lowess Lab_ch_08_12 distance, lwidth(1) lcolor(1)
graph export FigureA4.pdf, replace



***************************************************
* Figure A5: CDF of arrested rioters across wards *
***************************************************

clear
use mayor_elections.dta
cdfplot charged, normal
graph export FigureA5.pdf, replace



******************************************************************************************
* Table A5: Use weighted linear regression (WLS) to check for robustness of EI estimates *
******************************************************************************************

clear
use mayor_elections.dta

gen yearD=1
gen boroughD=1
gen constant=1

label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"


* Turnout (whites)
gen weight_turn_w=1/sbeta_turn_w
xi: regwls beta_turn_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, wvar(weight_turn_w) type(abse) robust
outreg2 using TableA5, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab replace alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, robust, Estimation, OLS)

xi: regwls beta_turn_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, wvar(weight_turn_w) type(abse) robust
outreg2 using TableA5, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, robust, Estimation, OLS)


* Turnout (Blacks)
gen weight_turn_b=1/sbeta_turn_b
xi: regwls beta_turn_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, wvar(weight_turn_b) type(abse) robust
outreg2 using TableA5, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, robust, Estimation, OLS)

xi: regwls beta_turn_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, wvar(weight_turn_b) type(abse) robust
outreg2 using TableA5, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, robust, Estimation, OLS)


* Vote Conservative (whites)
gen weight_w=1/sbeta_w
xi: regwls beta_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, wvar(weight_w) type(abse) robust
outreg2 using TableA5, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, robust, Estimation, OLS)

xi: regwls beta_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, wvar(weight_w) type(abse) robust
outreg2 using TableA5, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, robust, Estimation, OLS)


* Vote Conservative (Blacks)
gen weight_b=1/sbeta_b
xi: regwls beta_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, wvar(weight_b) type(abse) robust
outreg2 using TableA5, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, robust, Estimation, OLS)

xi: regwls beta_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, wvar(weight_b) type(abse) robust
outreg2 using TableA5, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, robust, Estimation, OLS)




********************************
* Figure A6: Coefficient plots *
* (See bottom of this file)    *
********************************



************************************************************************************************************
* Table A6: Robustness to categorizing as 'treated' only those with more than the median number of charged *
************************************************************************************************************

clear
use mayor_elections.dta

gen yearD=1
gen boroughD=1
gen constant=1

label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"

egen med_charged=median(charged)
replace charged_d=0 if charged<=med_charged

* Turnout
xi: ols_spatial_HAC turnout_pc treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA6, tex(frag) auto(2) asterisk(se) ctitle(turnout) replace sortvar(time treated did charged_d did_charged) label alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC turnout_pc charged_d did_charged  fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA6, tex(frag) auto(2) asterisk(se) ctitle(turnout) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Share Consevative vote
xi: ols_spatial_HAC share_total_Con treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA6, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Con charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA6, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)



***************************************************
* Table A7: Replicate Table 1 for 0.5-1 and 1-1.5 *
***************************************************

clear
use robustness_distance.dta

gen yearD=1
gen boroughD=1
gen constant=1

drop if distance>1500
gen treated = (distance < 1000)
drop if distance<500

gen time = (year>=2011)
gen did = time*treated

gen time2 = (year>=2006)
gen Ldid= time2*treated


gen charged_d = 0
replace charged_d=1 if charged>0
gen did_charged=charged_d * time

label var charged_d "treat (near rioter)"
label var did_charged "treat (near rioter) x post (did)"

count if treated==1 & charged_d==1
count if treated==1 & charged_d==0
count if treated==0 & charged_d==1
count if treated==0 & charged_d==0

* Define the panel variables
gen id = borough + ward_mayor
encode id, gen(idN)
tsset idN year


label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

drop did
gen did = time*treated


* Turnout
xi: ols_spatial_HAC turnout_pc treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA7, tex(frag) auto(2) asterisk(se) ctitle(turnout) replace sortvar(time treated did charged_d did_charged) label alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC turnout_pc charged_d did_charged  fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA7, tex(frag) auto(2) asterisk(se) ctitle(turnout) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Share Conservative vote
xi: ols_spatial_HAC share_total_Con treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA7, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Con charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA7, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)






***************************************************
* Table A8: Replicate Table 1 for 0.5-2 and 2-3.5 *
***************************************************

clear
use robustness_distance.dta

gen yearD=1
gen boroughD=1
gen constant=1

drop if distance>3500
gen treated = (distance < 2000)
drop if distance<500

gen time = (year>=2011)
gen did = time*treated

gen time2 = (year>=2006)
gen Ldid= time2*treated


gen charged_d = 0
replace charged_d=1 if charged>0
gen did_charged=charged_d * time

label var charged_d "treat (near rioter)"
label var did_charged "treat (near rioter) x post (did)"

count if treated==1 & charged_d==1
count if treated==1 & charged_d==0
count if treated==0 & charged_d==1
count if treated==0 & charged_d==0

* Define the panel variables
gen id = borough + ward_mayor
encode id, gen(idN)
tsset idN year


label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

drop did
gen did = time*treated


* Turnout
xi: ols_spatial_HAC turnout_pc treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA8, tex(frag) auto(2) asterisk(se) ctitle(turnout) replace sortvar(time treated did charged_d did_charged) label alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC turnout_pc charged_d did_charged  fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA8, tex(frag) auto(2) asterisk(se) ctitle(turnout) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Share Conservative vote
xi: ols_spatial_HAC share_total_Con treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA8, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Con charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA8, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)







***********************************************
* Table A9: Replicate Table 1 for 0-2 and 2-4 *
***********************************************

clear
use robustness_distance.dta

gen yearD=1
gen boroughD=1
gen constant=1

drop if distance>4000
gen treated = (distance < 2000)

gen time = (year>=2011)
gen did = time*treated

gen time2 = (year>=2006)
gen Ldid= time2*treated


gen charged_d = 0
replace charged_d=1 if charged>0
gen did_charged=charged_d * time

label var charged_d "treat (near rioter)"
label var did_charged "treat (near rioter) x post (did)"

count if treated==1 & charged_d==1
count if treated==1 & charged_d==0
count if treated==0 & charged_d==1
count if treated==0 & charged_d==0

* Define the panel variables
gen id = borough + ward_mayor
encode id, gen(idN)
tsset idN year


label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

drop did
gen did = time*treated


* Turnout
xi: ols_spatial_HAC turnout_pc treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA9, tex(frag) auto(2) asterisk(se) ctitle(turnout) replace sortvar(time treated did charged_d did_charged) label alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC turnout_pc charged_d did_charged  fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA9, tex(frag) auto(2) asterisk(se) ctitle(turnout) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Share Conservative vote
xi: ols_spatial_HAC share_total_Con treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA9, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC share_total_Con charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA9, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)



**************************************************************************************************************
* Table A10: Placebo test: within 5km of Charing Cross is treatment, 5-10km from Charing Cross is control.   *
* This covers most of the central London boroughs 															 *
**************************************************************************************************************

clear
* This dataset includes distances to Charing Cross station in central London.
use placebo1.dta

gen yearD=1
gen boroughD=1
gen constant=1

drop if distance_charing_cross>15000
gen treated = (distance_charing_cross < 7500)

gen time = (year>=2011)
gen did = time*treated


* Define the panel variables
gen id = borough + ward_mayor
encode id, gen(idN)
tsset idN year


label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

drop did
gen did = time*treated


* Turnout
xi: ols_spatial_HAC turnout_pc treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA10, tex(frag) auto(2) asterisk(se) ctitle(turnout) replace sortvar(time treated did charged_d did_charged) label alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Share Conservative Vote
xi: ols_spatial_HAC share_total_Con treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA10, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)






**********************************************************************************************************
* Table A11: Placebo test: use 'made up' riot locations chosen to match actual locations on fundamentals *
**********************************************************************************************************

clear
* This dataset has the distances to the counterfactual riot locations (chosen to be the LSOA in a different borough with fundamentals that are most 
* similar to those in a riot location.
use placebo2.dta


gen yearD=1
gen boroughD=1
gen constant=1

drop if placebo_distance>5500
gen treated = (placebo_distance < 3000)
drop if placebo_distance<500

gen time = (year>=2011)
gen did = time*treated

gen time2 = (year>=2006)
gen Ldid= time2*treated


gen charged_d = 0
replace charged_d=1 if charged>0
gen did_charged=charged_d * time

label var charged_d "treat (near rioter)"
label var did_charged "treat (near rioter) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

count if treated==1 & charged_d==1
count if treated==1 & charged_d==0
count if treated==0 & charged_d==1
count if treated==0 & charged_d==0

* Define the panel variables
gen id = borough + ward_mayor
encode id, gen(idN)
tsset idN year


label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"

drop did
gen did = time*treated



* Turnout
xi: ols_spatial_HAC turnout_pc treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA11, tex(frag) auto(2) asterisk(se) ctitle(turnout) replace sortvar(time treated did charged_d did_charged) label alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

* Share Conservative vote
xi: ols_spatial_HAC share_total_Con treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA11, tex(frag) auto(2) asterisk(se) ctitle(share Con) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)




****************************************************
* Table A12: Replicate Table 2 for 0.5-1 and 1-1.5 *
****************************************************

clear
use robustness_distance.dta

* This is to avoid having a year adjustment
gen yearD=1
gen boroughD=1
gen constant=1

drop if distance>1500
gen treated = (distance < 1000)
drop if distance<500

gen time = (year>=2011)
gen did = time*treated

gen time2 = (year>=2006)
gen Ldid= time2*treated


gen charged_d = 0
replace charged_d=1 if charged>0
gen did_charged=charged_d * time

label var charged_d "treat (near rioter)"
label var did_charged "treat (near rioter) x post (did)"

count if treated==1 & charged_d==1
count if treated==1 & charged_d==0
count if treated==0 & charged_d==1
count if treated==0 & charged_d==0

* Define the panel variables
gen id = borough + ward_mayor
encode id, gen(idN)
tsset idN year


label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

drop did
gen did = time*treated


* Turnout (whites)
xi: ols_spatial_HAC beta_turn_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA12, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab replace alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_turn_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA12, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Turnout (Blacks)
xi: ols_spatial_HAC beta_turn_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA12, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_turn_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA12, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Vote Conservative (whites)
xi: ols_spatial_HAC beta_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA12, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA12, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

* Vote Conservative (Blacks)
xi: ols_spatial_HAC beta_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA12, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA12, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)






****************************************************
* Table A13: Replicate Table 2 for 0.5-2 and 2-3.5 *
****************************************************

clear
use robustness_distance.dta

gen yearD=1
gen boroughD=1
gen constant=1

drop if distance>3500
gen treated = (distance < 2000)
drop if distance<500

gen time = (year>=2011)
gen did = time*treated

gen time2 = (year>=2006)
gen Ldid= time2*treated


gen charged_d = 0
replace charged_d=1 if charged>0
gen did_charged=charged_d * time

label var charged_d "treat (near rioter)"
label var did_charged "treat (near rioter) x post (did)"

count if treated==1 & charged_d==1
count if treated==1 & charged_d==0
count if treated==0 & charged_d==1
count if treated==0 & charged_d==0

* Define the panel variables
gen id = borough + ward_mayor
encode id, gen(idN)
tsset idN year


label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

drop did
gen did = time*treated

* Turnout (whites)
xi: ols_spatial_HAC beta_turn_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA13, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab replace alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_turn_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA13, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Turnout (Blacks)
xi: ols_spatial_HAC beta_turn_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA13, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_turn_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA13, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Vote Conservative (whites)
xi: ols_spatial_HAC beta_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA13, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA13, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

* Vote Conservative (Blacks)
xi: ols_spatial_HAC beta_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA13, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA13, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)







************************************************
* Table A14: Replicate Table 2 for 0-2 and 2-4 *
************************************************

clear
use robustness_distance.dta

gen yearD=1
gen boroughD=1
gen constant=1

drop if distance>4000
gen treated = (distance < 2000)

gen time = (year>=2011)
gen did = time*treated

gen time2 = (year>=2006)
gen Ldid= time2*treated


gen charged_d = 0
replace charged_d=1 if charged>0
gen did_charged=charged_d * time

label var charged_d "treat (near rioter)"
label var did_charged "treat (near rioter) x post (did)"

count if treated==1 & charged_d==1
count if treated==1 & charged_d==0
count if treated==0 & charged_d==1
count if treated==0 & charged_d==0

* Define the panel variables
gen id = borough + ward_mayor
encode id, gen(idN)
tsset idN year


label var treated "treated (near riot)"
label var time "post"
label var did "treated (near riot) x post (did)"
label var fraction_black "fraction black"
label var fraction_white "fraction white"
label var fraction_high_qual "fraction high qualifications"
label var crime_rate10 "crime rate (2010)"

drop did
gen did = time*treated

* Turnout (whites)
xi: ols_spatial_HAC beta_turn_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA14, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab replace alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_turn_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA14, tex(frag) auto(2) asterisk(se) ctitle(turnout white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Turnout (Blacks)
xi: ols_spatial_HAC beta_turn_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA14, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_turn_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA14, tex(frag) auto(2) asterisk(se) ctitle(turnout blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)


* Vote Conservative (whites)
xi: ols_spatial_HAC beta_w treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA14, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_w charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA14, tex(frag) auto(2) asterisk(se) ctitle(share Con white) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

* Vote Conservative (Blacks)
xi: ols_spatial_HAC beta_b treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA14, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)

xi: ols_spatial_HAC beta_b charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
outreg2 using TableA14, tex(frag) auto(2) asterisk(se) ctitle(share Con blacks) sortvar(time treated did charged_d did_charged) lab append alpha(0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) drop(_I*) addtext(Fixed effect, borough, Standard errors, Conley, Estimation, OLS)



*************
* Figure A6 *
*************

* Turnout *
xi: ols_spatial_HAC turnout_pc treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
estimates store tab1a

xi: ols_spatial_HAC turnout_pc charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
estimates store tab1b


* Vote against the Tories *

xi: ols_spatial_HAC share_total_Con treated did fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
estimates store tab1c

xi: ols_spatial_HAC share_total_Con charged_d did_charged fraction_black fraction_white unemployment fraction_high_qual crime_rate10 i.year i.borough, panelvar(ward_mayorN) timevar(year) lat(latitude) lon(longitude) disp
estimates store tab1d


#delimit ;
coefplot
(tab1a tab1b), bylabel(Turnout) ||
(tab1c tab1d), bylabel(Conservative vote share) ||,
drop(fraction_black fraction_white unemployment fraction_high_qual crime_rate10 _Iyear* _Iborough*) omitted xline(0, lcolor(black) lwidth(thin))
;
graph export FigureA6.pdf, replace

